home *** CD-ROM | disk | FTP | other *** search
/ Delphi 2 - Developers' Solutions / Delphi 2 Developers' Solutions.iso / dds / chap03 / howto08 / dddfunit.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-10-12  |  1.4 KB  |  59 lines

  1. unit Dddfunit;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, FileCtrl, ExtCtrls, Buttons, Grids, Outline,
  8.   DirOutln;
  9.  
  10. type
  11.   TDestDDForm = class(TForm)
  12.     Panel1: TPanel;
  13.     Panel2: TPanel;
  14.     DriveComboBox1: TDriveComboBox;
  15.     BitBtn1: TBitBtn;
  16.     BitBtn2: TBitBtn;
  17.     Panel3: TPanel;
  18.     Label1: TLabel;
  19.     DirectoryListBox1: TDirectoryListBox;
  20.     procedure FormCreate(Sender: TObject);
  21.     procedure DirectoryListBox1Change(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.     function GetTargetDirectory : String;
  27.   end;
  28.  
  29. var
  30.   DestDDForm: TDestDDForm;
  31.  
  32. implementation
  33.  
  34. {$R *.DFM}
  35.  
  36. { Delphi wrote this; use it to set up the path label }
  37. procedure TDestDDForm.FormCreate(Sender: TObject);
  38. begin
  39.   Label1.Caption := DirectoryListBox1.Directory;
  40. end;
  41.  
  42.  
  43. { Use this to get a correctly \-terminated pathname }
  44. function TDestDDForm.GetTargetDirectory : String;
  45. var TheString : String;
  46. begin
  47.   TheString := DirectoryListBox1.Directory;
  48.   if TheString[ Length( TheString )] = '\' then GetTargetDirectory
  49.    := TheString else GetTargetDirectory := TheString + '\';
  50. end;
  51.  
  52. procedure TDestDDForm.DirectoryListBox1Change(Sender: TObject);
  53. begin
  54.   Label1.Caption := DirectoryListBox1.Directory;
  55.   Label1.Show;
  56. end;
  57.  
  58. end.
  59.